package com.isky.visual.db.service.impl;

import com.isky.visual.db.entity.MetaData;
import com.isky.visual.db.mapper.MetaDataMapper;
import com.isky.visual.db.service.IMetaDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isky.visual.result.CodeMsg;
import com.isky.visual.result.ResultVo;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 元数据表 服务实现类
 * </p>
 *
 * @author wudl
 * @since 2020-04-15
 */
@Service("IMetaDataService")
public class MetaDataServiceImpl extends ServiceImpl<MetaDataMapper, MetaData> implements IMetaDataService {

    @Autowired
    MetaDataMapper metaDataMapper;
    @Override
    public ResultVo<String> addMetaData(MetaData metaData) {
        int insert = metaDataMapper.insert(metaData);
        return ResultVo.success(CodeMsg.DB_ADDDATA_SUCCESS.getMsg());
    }

    @Override
    public ResultVo<String> delMetaData(MetaData metaData) {
        int byId = metaDataMapper.deleteById(metaData.getId());
        System.out.println("****"+byId);
        return ResultVo.success(CodeMsg.DB_DELETE_SUCCESS.getMsg());
    }

    @Override
    public ResultVo<String> updateMetaData(MetaData metaData) {
        int update = metaDataMapper.update(metaData, null);
        System.out.println("update"+update);
        return ResultVo.success(CodeMsg.DB_UPDATE_SUCCESS.getMsg());
    }

    @Override
    public ResultVo<List<MetaData>> queryMetaData(MetaData metaData) {
        List<MetaData> metaDataList = metaDataMapper.selectList(null);
        return ResultVo.success(metaDataList);
    }
}
